#!/bin/bash
# 
# svnbackup.sh
# Dumps all SVN-Repos from a given location gzip compressed to a folder
# 
# Copyright (C) 2008 by Thomas Deutsch <thomas@tuxpeople.org>
#
# License:  WTFPL - Do What The Fuck You Want To Public License
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
# 

# Variables. NO TRAILING SLASHES:
# 
REPODIR="/export/dat/subversion"	# Where are the repositories on the filesystem?
TARGETDIR="/export2/svn_dump"		# Where should the dump be stored on the filesystem?

# Step 1: Delete old dumps
#
echo "Deleting old dumps from ${TARGETDIR}..."
rm -rf ${TARGETDIR}/svn_dump_*
echo "finished..."

# Step 2: Create new dumps
#
echo "Now starting with dumps to ${TARGETDIR}..."
for TARGET in $(ls ${REPODIR})
do
	echo "Dumping ${TARGET} to ${TARGETDIR}..."
	svnadmin dump ${REPODIR}/${TARGET} | gzip -c > ${TARGETDIR}/svn_dump_${TARGET}_$(date +%Y%m%d).dump.gz
	echo "Dumping ${TARGET} finished..."
done
echo "All Tasks done. If you haven't seen an error, everything is fine."